
CREATE PROCEDURE [dbo].[PurchaseLand] 
	@Game_ID numeric(10,0) = null,
	@Land_ID numeric(10,0) = null,
	@Buyer_Player_ID numeric(10,0) = null,
	@Seller_Player_ID numeric(10,0) = null,
	@Price int = null
AS
BEGIN 
	
	UPDATE 
		[dbo].[PlayerAsset] 
	SET 
		Currency = Currency - @Price 
	WHERE 
		Game_ID = @Game_ID
		and IsActive = 'Y' 
		and Player_ID = @Buyer_Player_ID 
		and AssetType = 'Cash'
		
	UPDATE 
		[dbo].[PlayerAsset] 
	SET 
		Player_ID = @Buyer_Player_ID
	WHERE 
		Game_ID = @Game_ID
		and IsActive = 'Y'
		and Player_ID = @Seller_Player_ID
		and AssetType = 'Fixed'
		and Land_ID = @Land_ID
		
	
	
	UPDATE 
		[dbo].[PlayerAsset] 
	SET 
		Currency = Currency + @Price 
	WHERE 
		Game_ID = @Game_ID
		and IsActive = 'Y'
		and Player_ID = @Seller_Player_ID 
		and AssetType = 'Cash'
END
 
-- [dbo].[PurchaseLand]  @Game_ID=1,@Land_ID=11,@Buyer_Player_ID=3,@Seller_Player_ID=1,@Price=300
